home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac-Source 1994 July
/
Mac-Source_July_1994.iso
/
C and C++
/
Commun⁄Network
/
NetNews Sample Code ƒ
/
News src
/
bits.h
< prev
next >
Wrap
Text File
|
1990-10-14
|
946b
|
35 lines
/*
* bitmap set/clear/test operations
* Copyright © Tom Bereiter, 1990
*/
#define _H_bits
typedef unsigned long bitmap_t;
#define BitsPerByte 8
#define BitsPerLong 32
#define LogBitsPerByte 3
#define LogBitsPerLong 5
#define ALLONES (bitmap_t)~0
/* set single bit */
#define Bset(bmp, bitnum) \
(*(bmp + (bitnum >> LogBitsPerLong)) |= 1L << (bitnum & (BitsPerLong-1)))
/* clear single bit */
#define Bclr(bmp, bitnum) \
(*(bmp + (bitnum >> LogBitsPerLong)) &= ~(1L << (bitnum & (BitsPerLong-1))))
/* test single bit */
#define Btst(bmp, bitnum) \
(*(bmp + (bitnum >> LogBitsPerLong)) & (1L << (bitnum & (BitsPerLong-1))))
extern bitmap_t *bmalloc(unsigned long n);
extern void bfset(bitmap_t *, unsigned long, unsigned long);
extern void bfclr(bitmap_t *, unsigned long, unsigned long);
extern unsigned long bfffs(bitmap_t *, unsigned long, unsigned long);
extern unsigned long bfffc(bitmap_t *, unsigned long, unsigned long);